unit ConnectionWindow;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Process;

type

  { TForm2 }

  TForm2 = class(TForm)
    Button1: TButton;
    ConnectionsList: TListBox;
    procedure Button1Click(Sender: TObject);
    procedure ConnectionsListDblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.lfm}

{ TForm2 }

procedure TForm2.FormCreate(Sender: TObject);
begin
  ConnectionsList.Items.LoadFromFile('connections.ini');
end;

procedure TForm2.Button1Click(Sender: TObject);
var NewProcess: TProcess;
begin
  if (ConnectionsList.GetSelectedText = '') then exit;
  NewProcess := TProcess.Create(nil);
  NewProcess.CommandLine := paramstr(0) + ' '+ConnectionsList.GetSelectedText;
//  NewProcess.Options := NewProcess.Options + [poWaitOnExit];
  NewProcess.Execute;
  NewProcess.Free;
  close;
end;

procedure TForm2.ConnectionsListDblClick(Sender: TObject);
begin
  Button1Click(Sender);
end;

end.
